import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/common/xindong_all.dart';
import 'package:xindong/models/xindong_setting_class.dart';
import 'package:xindong/utils/xindong_image_util.dart';

class XinDongWoDeItemWidget extends StatelessWidget {
  final XinDongSettingClass model;
  final Color backgroundColor;
  final Function() onTap;

  const XinDongWoDeItemWidget({super.key, required this.model, this.backgroundColor = DZColors.cellColor, required this.onTap});

  @override
  Widget build(BuildContext context) {
    const titleTextStyle = TextStyle(color: DZColors.titleColor, fontSize: 16.0, fontWeight: FontWeight.normal, height: 1.2);
    const mainTextStyle = TextStyle(color: DZColors.mainColor, fontSize: 16.0, fontWeight: FontWeight.normal, height: 1.2);
    return GestureDetector(
      onTap: onTap,
      behavior: HitTestBehavior.opaque,
      child: Container(
        height: kCellHeight,
        color: backgroundColor,
        padding: const EdgeInsets.only(left: 10, right: 6),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.end,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            if (model.icon != null)
              Padding(
                padding: const EdgeInsets.only(right: 10),
                child: model.icon is Widget ? model.icon : ImageUtil.asset(model.icon, width: 30, height: 30),
              ),
            Expanded(
              child: Text(model.title, style: titleTextStyle),
            ),
            Text(model.content, style: mainTextStyle),
            model.hideMore ? const SizedBox(width: 10) : XinDongAll.instance.defaultIconNext,
          ],
        ),
      ),
    );
  }
}

class XinDongWoDeTextCenterItemWidget extends StatelessWidget {
  final XinDongSettingClass model;
  final Color backgroundColor;
  final Function() onTap;

  const XinDongWoDeTextCenterItemWidget({super.key, required this.model, this.backgroundColor = Colors.white, required this.onTap});

  @override
  Widget build(BuildContext context) {
    const mainTextStyle = TextStyle(color: DZColors.mainColor, fontSize: 16.0, fontWeight: FontWeight.normal, height: 1.2);
    return GestureDetector(
      onTap: onTap,
      behavior: HitTestBehavior.opaque,
      child: Container(
        height: kCellHeight,
        color: backgroundColor,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text(model.title, style: mainTextStyle),
          ],
        ),
      ),
    );
  }
}
